<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="css/eui.css">
</head>
<body>

<div id="app">
    <!--页头组件-->
    <el-page-header style="background-color: #0095d7;color: white;line-height: 60px"
                    @back="goBack" content="修改管理员信息页面"></el-page-header>
    <!--分割线-->
    <el-divider></el-divider>
    <!--name代表上传文件时 文件的参数名
        limit="1" 设置只能选择一张图片
    -->
    <el-card>
        <el-form>
            <el-form-item label="用户名" label-width="80px">
                <el-input v-model="admin.username"></el-input>
            </el-form-item>
            <el-form-item label="密码" label-width="80px">
                <el-input v-model="admin.password"></el-input>
            </el-form-item>
            <el-form-item label="昵称" label-width="80px">
                <el-input v-model="admin.nickname"></el-input>
            </el-form-item>
<!--            <el-form-item label="电话" label-width="80px">-->
<!--                <el-input v-model="admin.phone"></el-input>-->
<!--            </el-form-item>-->
<!--            <el-form-item label="电子邮件" label-width="80px">-->
<!--                <el-input v-model="admin.email"></el-input>-->
<!--            </el-form-item>-->
            <el-form-item label="描述" label-width="80px">
                <el-input v-model="admin.description"></el-input>
            </el-form-item>
            <el-form-item label="是否启用" label-width="80px">
                <el-input v-model="admin.isEnable"></el-input>
            </el-form-item>
        </el-form>
        <el-button @click="adminUpdate()">修改</el-button>
    </el-card>
</div>
</body>
<!-- import Vue before Element -->
<script src="js/vue.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                admin: {}
            }
        },
        created:function (){
            //获取需要修改的管理员数据库的账号信息
            let id = location.search.split("=")[1];
            axios.get("/admin/selectById?id="+id).then(function (response){
                v.admin=response.data;
            })
        },
        methods: {
            adminUpdate(){
                axios.post("/admin/updateAdmin",v.admin).then(function (response) {
                    alert("修改完成!");
                    location.href="/admin.html";
                })
            },
            goBack() {
                //返回上一页面
                history.back();
            }
        },
    })
</script>
</html>

<!--
use cs;
create table product(id int primary key auto_increment,title varchar(100),url varchar(255),price double(10,2),old_price double(10,2),view_count int,sale_count int,created timestamp, category_id int)charset=utf8;

-->